import pandas as pd, pickle, numpy as np, matplotlib.pyplot as plt, matplotlib.dates as mdates, matplotlib as mpl
import matplotlib.lines as mlines
from datetime import datetime, timedelta
#%run safegraph_census.ipynb
%run create_master_table.ipynb
-------------------- Census Data -------------------- Enigma Aggregation Shape: (583062, 10) Case control total: 602329120.0 Death control total: 22406363.0 Dataframe Shape: (583062, 14) Number of States: 55 Number of Counties: 3211 Minimum Date: 2020-01-21 00:00:00 Maximum Date: 2020-09-29 00:00:00 Duplicate State-Fips-Date: 0 Null State Code: 0 Null County Code: 0 Null Dates: 0 Case Control Total: 602329120.0 Death Control Total: 22406363.0 -------------------- Enigma Johns Hopkins Shape: (419379, 14) Case control total: 62110114.0 Death control total: 3522063.0 Dataframe Shape: (419379, 18) Number of States: 51 Number of Counties: 3201 Minimum Date: 2020-01-22 00:00:00 Maximum Date: 2020-05-29 00:00:00 Duplicate State-Fips-Date: 0 Null State Code: 0 Null County Code: 0 Null Dates: 0 Case Control Total: 62110114.0 Death Control Total: 3522063.0 -------------------- Enigma New York Times Shape: (129747, 6) Case control total: 31616769.0 Death control total: 1652495.0 Dataframe Shape: (129747, 10) Number of States: 55 Number of Counties: 2885 Minimum Date: 2020-01-21 00:00:00 Maximum Date: 2020-05-09 00:00:00 Duplicate State-Fips-Date: 0 Null State Code: 0 Null County Code: 0 Null Dates: 0 Case Control Total: 31616769.0 Death Control Total: 1652495.0 -------------------- Rearc New York Times Shape: (1348971, 6) Case control total: 5848040258.0 Death control total: 119091374.0 Dataframe Shape: (1348971, 10) Number of States: 55 Number of Counties: 3221 Minimum Date: 2020-01-21 00:00:00 Maximum Date: 2021-05-23 00:00:00 Duplicate State-Fips-Date: 0 Null State Code: 0 Null County Code: 0 Null Dates: 0 Case Control Total: 5848040258.0 Death Control Total: 119091374.0 -------------------- USA Facts - CDC Shape: (1558184, 8) Case control total: 5745715395.0 Death control total: 117502551.0 Dataframe Shape: (1558184, 12) Number of States: 51 Number of Counties: 3143 Minimum Date: 2020-01-22 00:00:00 Maximum Date: 2021-05-23 00:00:00 Duplicate State-Fips-Date: 0 Null State Code: 0 Null County Code: 0 Null Dates: 0 Case Control Total: 5745715395.0 Death Control Total: 117502551.0 -------------------- Google Mobility -------------------- Joining Data -------------------- Saving data to covid_data.p -------------------- Control Totals -------------------- Census Data -------------------- Cases 0.0 0.0 0.0 0.0 0.0 -------------------- Deaths 0.0 0.0 0.0 0.0 0.0
with open('covid_data.p', 'rb') as f:
data = pickle.load(f)
%run graphFunctions.ipynb
# Remove this next run, it is only to correct for no data uploads on the most recent days if report is generated over weekend
#data = data[data.date!='2021-04-02']
print("Total Deaths :", data[data.date == data.date.max()- timedelta(days=1)].deaths_cdc.sum())
Total Deaths : 583029.0
plotStateTotals(data, 'deaths_cdc', 'deaths_cdc', 200)
plotStateTotals(data, 'deaths_cdc', 'deaths_cdc_per_100k', 200)
states=data.state_code.unique()
stateGraphs(data, states,'confirmed_cdc','deaths_cdc', '2020-03-01', 21)
states = getStatesInRegion("N").keys()
stateGraphs(data, states,'confirmed_cdc','deaths_cdc', '2020-03-01', 21)
states = getStatesInRegion("S").keys()
stateGraphs(data, states,'confirmed_cdc','deaths_cdc', '2020-03-01', 21)
states = getStatesInRegion("M").keys()
stateGraphs(data, states,'confirmed_cdc','deaths_cdc', '2020-03-01', 21)
states = getStatesInRegion("W").keys()
stateGraphs(data, states,'confirmed_cdc','deaths_cdc', '2020-03-01', 21)
states = getStatesInRegion("N").keys()
statesCompare(data, states, 'confirmed_cdc', 'deaths_cdc', '2020-03-01', 14)
states = getStatesInRegion("S").keys()
statesCompare(data, states, 'confirmed_cdc', 'deaths_cdc', '2020-03-01', 14)
states = getStatesInRegion("M").keys()
statesCompare(data, states, 'confirmed_cdc', 'deaths_cdc', '2020-03-01', 14)
states = getStatesInRegion("W").keys()
statesCompare(data, states, 'confirmed_cdc', 'deaths_cdc', '2020-03-01', 14)
states = list(data.state_code.unique())
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='pop_density_grp', start_date='2020-03-01')
The race definition used here is 'white' as reported in census data. Low would be 'non-white' and high would be 'white'.
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='r_w_grp', start_date='2020-03-01')
'Low' are the counties with the lowest percentages of uninsured individuals.
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='unins_grp', start_date='2020-03-01')
'High' are the counties with the highest percentage of PIR > 200%
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='pir_grp', start_date='2020-03-01')
'High' is 'Republican' and 'Low' is 'Democrat' vote in 2020 presidential election.
states=data.state_code.unique()
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='rep', start_date='2020-03-01')
states = getStatesInRegion("N").keys()
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='rep', start_date='2020-03-01')
states = getStatesInRegion("S").keys()
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='rep', start_date='2020-03-01')
states = getStatesInRegion("M").keys()
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='rep', start_date='2020-03-01')
states = getStatesInRegion("W").keys()
plotGroupedDeathCurves(data, states=states, rolling_ave=30, bycol='rep', start_date='2020-03-01')
state = 'NY'
death_min = 500
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'CA'
death_min = 600
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'TX'
death_min = 500
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'FL'
death_min = 500
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'NJ'
death_min = 500
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'PA'
death_min = 500
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'IL'
death_min = 300
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'MA'
death_min = 300
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'AZ'
death_min = 300
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'MI'
death_min = 300
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'OH'
death_min = 300
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)
state = 'IN'
death_min = 300
stateGraphs(data, [state],'confirmed_cdc','deaths_cdc', '2020-03-01', 7)
plotCountyDeathCurves(data, state, death_min = death_min, rolling_ave = 14, start_date='2020-03-14')
graphMobilityCounty(data, state, '2020-03-01', 1, death_min = death_min)
graphMobilityCounty(data, state, '2020-03-01', 14, death_min = death_min)